﻿using System;
using System.Globalization;
using System.Xml.Linq;
using WeiboSharp;

namespace WeiboEx.Models
{
    public class Status
    {
        public long Id { get; set; }
        public string Text { get; set; }
        public string ThumbnailPic { get; set; }
        public string CreateAt { get; set; }

        public static Status Create(XElement status)
        {
            return new Status
                       {
                           Id = Convert.ToInt64(status.GetString("id")),
                           Text = status.GetString("text"),
                           ThumbnailPic = status.GetString("thumbnail_pic"),
                           CreateAt = DateTime.ParseExact(status.GetString("created_at"),
                                            "ddd MMM dd HH:mm:ss zz00 yyyy",
                                             new CultureInfo("en-US"),
                                             DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)
                                             .ToString("yyyy-MM-dd HH:mm")
                       };
        }
    }
}
